package com.liang.controller;


import com.liang.empty.Result;
import com.liang.pojo.Userzdutyzx;
import com.liang.service.UserzdutyzxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

;

/**
 *@作者:lsk
 *Controller接口
 *@Date:2023/10/23
*/
@RestController
@RequestMapping("/UserzdutyzxURL")
public class UserzdutyzxController {


	@Autowired
	private UserzdutyzxService userzdutyzxservice;




	/**
	 insert:(插入)
	*/
	@PostMapping("/insert")
	public Result insert(@RequestBody Userzdutyzx demo){
		Result.buildSuccess(userzdutyzxservice.insert(demo));
		return Result.buildMessage(demo,"添加成功",0);
	}



	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	@PostMapping("/insertOrUpdate")
	public Result insertOrUpdate(@RequestBody Userzdutyzx demo){
		return Result.buildMessage(userzdutyzxservice.insertOrUpdate(demo),"插入或更新成功",200);
	}



	/**
	 insertBath:(批量插入)
	*/
	@PostMapping("/insertBatch")
	public Result insertBatch(@RequestBody List<Userzdutyzx> list){
		return Result.buildMessage(userzdutyzxservice.insertBatch(list),"批量插入成功",200);
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	@PostMapping("/insertOrUpdateBatch")
	public Result insertOrUpdateBatch(@RequestBody List<Userzdutyzx> list){
		return Result.buildMessage(userzdutyzxservice.insertOrUpdateBatch(list),"批量更新成功",200);
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	@PostMapping("/selectList")
	public Result selectList(@RequestBody Map<String,Object> param){
		Map map = new HashMap<String,Object>();
		if(param.get("pageNum") != null){
			map.put("total",userzdutyzxservice.selectCount(param));
		}
		map.put("data",userzdutyzxservice.selectList(param));
		return Result.buildMessage(map,"查询成功",200);
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	@PostMapping("/selectCount")
	public Result selectCount(@RequestBody Map<String,Object> param){
		return Result.buildMessage(userzdutyzxservice.selectCount(param),"查询数量成功",200);
	}


	/**
	 * 删除用户职位
	 */
	@PostMapping("/deleteUserDuty")
	public Result deleteUserDuty(@RequestBody Map map) {
		return Result.buildSuccess(userzdutyzxservice.deleteUserDuty(map));
	}


}